﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using POSSystem.BLL;

namespace WebUI.Controls
{
    public partial class AddServiceCtrl : BaseEditControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            base.Page_Load(sender, e);
            if (!IsPostBack)
            {
                Utilities.LoadDropDownList(ddlNetworks, Networks.GetAllActiveNetworks().DefaultView, Networks.ColumnNames.NetworkName,
                    Networks.ColumnNames.ID);
            }
        }

        public void DisableAmountEdit()
        {
            txtMPP.Visible = false;
            txtRebate.Visible = false;
            txtCommission.Visible = false;
            lblCommission.Visible = true;
            lblMPP.Visible = true;
            lblRebate.Visible = true;
        }

        public string MobileNumber
        {
            get { return txtMobile.Text; }
            set { txtMobile.Text = value; }
        }

        public string PlanDescription
        {
            get { return txtPlanDescription.Text; }
            set { txtPlanDescription.Text = value; }
        }

        public int NetworkID
        {
            get { return int.Parse(ddlNetworks.SelectedValue);}
            set { ddlNetworks.SelectedValue = value.ToString(); }
        }

        public string Network
        {
            get { return ddlNetworks.SelectedItem.Text; }
        }

        public byte PlanDuration
        {
            get { return byte.Parse(ddlPlanDuration.SelectedValue); }
            set { ddlPlanDuration.SelectedValue = value.ToString(); }
        }

        public Decimal Commission
        {
            get { return Decimal.Parse(txtCommission.Text); }
            set { txtCommission.Text = value.ToString(); lblCommission.Text = value.ToString(); }
        }

        public Decimal MPP
        {
            get { return Decimal.Parse(txtMPP.Text); }
            set { txtMPP.Text = value.ToString(); lblMPP.Text = value.ToString(); }
        }

        public Decimal Rebate
        {
            get { return Decimal.Parse(txtRebate.Text); }
            set { txtRebate.Text = value.ToString(); lblRebate.Text = value.ToString(); }
        }

        public DateTime? CreatedDate
        {
            get { return string.IsNullOrEmpty(txtCreatedDate.Text) ? null : (DateTime?)DateTime.ParseExact(txtCreatedDate.Text, SysVars.DateFormat, null); }
            set { if (value != null) txtCreatedDate.Text = ((DateTime)value).ToString(SysVars.DateFormat); else txtCreatedDate.Text = ""; }
        }

        public DateTime? StartDate
        {
            get { return string.IsNullOrEmpty(txtStartDate.Text) ? null : (DateTime?)DateTime.ParseExact(txtStartDate.Text, SysVars.DateFormat, null); }
            set { if (value != null) txtStartDate.Text = ((DateTime)value).ToString(SysVars.DateFormat); else txtStartDate.Text = ""; }
        }

        public DateTime? EndDate
        {
            get { return string.IsNullOrEmpty(txtEndDate.Text) ? null : (DateTime?)DateTime.ParseExact(txtEndDate.Text, SysVars.DateFormat, null); }
            set { if (value != null) txtEndDate.Text = ((DateTime)value).ToString(SysVars.DateFormat); else txtEndDate.Text = ""; }
        }
    }
}